#include "GenericButton.h"

/*
 * There are four classes in this file:
 * 
 * ButtonFromGeneric
 * ButtonFromJoystick
 * ButtonFromDriverStation
 * ButtonFromDigitalInput
 */



/*
 *  generic wrapper for the other three button classes
 */
ButtonFromGeneric::ButtonFromGeneric(GenericButton *button) :
	m_button(button)
{
	
}

bool ButtonFromGeneric::Get()
{
	return m_button->Get();
}


/*
 * ButtonFromJoystick class....
 * 
 */

// constructor, based on a button number on a joystick
ButtonFromJoystick::ButtonFromJoystick(Joystick *joystick, UINT32 button_number)
{
	m_joystick = joystick;
	m_button_number = button_number;
}

// is the button on the joystick pressed?
bool ButtonFromJoystick::Get()
{
	return m_joystick->GetRawButton(m_button_number);
}





/*
 * ButtonFromDriverStation class....
 * 
 */

// constructor, based on a channel on the driver station 
ButtonFromDriverStation::ButtonFromDriverStation(UINT32 channel)
{
	m_ds = DriverStation::GetInstance();
	m_channel = channel;
}

// is the button on the driver station pressed?
bool ButtonFromDriverStation::Get(void)
{
	return m_ds->GetDigitalIn(m_channel);
}





/*
 * ButtonFromDigitalInput class....
 * 
 */

// constructor, based on a digital input
ButtonFromDigitalInput::ButtonFromDigitalInput(DigitalInput *button)
{
	m_button = button; 
}

// constructor, based on a channel for a digital input
ButtonFromDigitalInput::ButtonFromDigitalInput(UINT32 channel)
{
	m_button = new DigitalInput(channel);
}

// constructor, based on a slot and channel for a digital input
ButtonFromDigitalInput::ButtonFromDigitalInput(UINT32 slot, UINT32 channel)
{
	m_button = new DigitalInput(slot, channel);
}

// is the button on the digital input pressed?
bool ButtonFromDigitalInput::Get(void)
{
	return m_button->Get();
}

